<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<%@page import="java.util.ArrayList"%>
<%@page import="java.util.List"%>
<%@page import="es.ats.codington.festival.domain.Event"%>


<!DOCTYPE html>
<html>
  <head>
    <title>PersonalVisitor</title>
    <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="css/bootstrap-theme.min.css">
    <script type="text/javascript" src="js/bootstrap.min.js"></script>
    <link rel="stylesheet" type="text/css" href="css/estilo.css">
    <script type="text/javascript" src="js/javascript.js"></script>

  </head>
 
  <body>

    <div class="cabecera"> 
      <h1 align="center">FESTIVAL REGISTRATION SYSTEM</h1>
    </div>

    <div id="login-overlay" class="modal-dialog">
    	<form action="LoginServlet" method="GET">
  			<button type="submit" class="btn btn-danger pull-right">Log Out</button>
 		</form>
 		
 		<form action="UpdatePeopleServlet" method="GET">
  			<button type="submit" class="btn btn-success pull-right">Update personal data</button>
 		</form>
 		
 		<form action="UpdatePasswordServlet" method="GET">
  			<button type="submit" class="btn btn-success pull-right">Change password</button>
 		</form>
 		
	</div>
          <div class="modal-header">
          <h3>
          Welcome @<%= (String)session.getAttribute("username") %>
          </h3>
          </div>
          

	<div class="container">
    <div class="row">
        <div class="panel panel-primary">
      
            <div class="panel-heading">
                <h3 class="panel-title">My Events</h3>
              
            </div>
            <table class="table">
            
              <%
              Event event=new Event();
               List<Event> eventList = new ArrayList<Event>();
               eventList = (ArrayList<Event>) session.getAttribute("eventsRegisteredList");
               %>

          
            
				<tr>
                	<thead>
					<tr >
						
						<th align="left">
							Event Name
						</th>
    					<th align="left">
							Place
						</th>
						
						<th align="left">
							Start Time
						</th>
						<th align="left">
							End Time
						</th>
						
						<th align="left">
							Day Event
						</th>
						<th align="left">
							Event Type
						</th>
						<th align="left">
							Seats Available
						</th>
						<th align="left">
							SignUp/SignOut
						</th>
        				<th class="text-center" style="border-top: 1px solid #ffffff; border-right: 1px solid #ffffff;">
						</th>
					</tr>
				</thead>
				<tbody>
			     <%for (int i=0;i<eventList.size();i++) {
                        event = eventList.get(i);
			     
                  %>
			     
					<tr> 
					<form action="UnregisterToEventServlet" method="POST">
					
						<input type="hidden" name="idEventMy" value=<%=event.getEventID()%>>
                        <td> <%=event.getName()%></td>
                        <td> <%=event.getPlace()%></td> 
						<td> <%=event.getStartEvent()%></td>
                        <td> <%=event.getEndEvent()%></td>
                        <td> <%=event.getDayEvent()%></td>
                        <td> <%=event.getEventType()%></td>
                        <td> <%=event.getSeatsAvailable()%></td>
						<td data-name="SignUp/SignOut">
						    
						<button type="submit" class="btn btn-success btn-block">Unregister</button>
						   
						</td>
				    </form>
					</tr>
			     <%
                  }
                  %>
					
				</tbody>
            </table>
              
        </div>
      </div>
   </div>
   
   <div class="container">
    <div class="row">
        <div class="panel panel-primary">
      
            <div class="panel-heading">
                <h3 class="panel-title">All Events</h3>
              
            </div>
            <table class="table">
            
              <%
              Event event1=new Event();
               List<Event> eventListAll = new ArrayList<Event>();
               eventListAll = (ArrayList<Event>) session.getAttribute("eventsList");
               %>

          
            
				<tr>
                	<thead>
					<tr >
						
						<th align="left">
							Event Name
						</th>
    					<th align="left">
							Place
						</th>
						
						<th align="left">
							Start Time
						</th>
						<th align="left">
							End Time
						</th>
						
						<th align="left">
							Day Event
						</th>
						<th align="left">
							Event Type
						</th>
						<th align="left">
							Seats Available
						</th>
						<th align="left">
							SignUp/SignOut
						</th>
        				<th class="text-center" style="border-top: 1px solid #ffffff; border-right: 1px solid #ffffff;">
						</th>
					</tr>
				</thead>
				<tbody>
			     <%for (int i=0;i<eventListAll.size();i++) {
                        event1 = eventListAll.get(i);
			     
                  %>
			     
					<tr> 
					<form action="RegisterToEventServlet" method="POST">
					
						<input type="hidden" name="idEventAll" value=<%=event1.getEventID()%>>
                        <td> <%=event1.getName()%></td>
                        <td> <%=event1.getPlace()%></td> 
						<td> <%=event1.getStartEvent()%></td>
                        <td> <%=event1.getEndEvent()%></td>
                        <td> <%=event1.getDayEvent()%></td>
                        <td> <%=event1.getEventType()%></td>
                        <td> <%=event1.getSeatsAvailable()%></td>
						<td data-name="SignUp/SignOut">
						<%if (event1.getSeatsAvailable() == 0) {%>
							<button type="submit" class="btn btn-danger btn-block" disabled>Full!</button>
						<% } else { %>
							<button type="submit" class="btn btn-success btn-block">Register</button>
						<% } %>
						
						 
						</td>
				    </form>
					</tr>
			     <%
                  }
                  %>
					
				</tbody>
            </table>
              
        </div>
      </div>
   </div>
 

    <div class="imgdiv">
      <img class="img">
    </div>

  </body>
</html>